//引入二次封装好的axios
import request from '@/utils/request';
import type { responseData, trademark } from './model/index';
//品牌管理模块接口地址
enum API {
    //获取已有品牌管理数据
    trademark = "/admin/product/baseTrademark/",
    addTrademark = "/admin/product/baseTrademark/save",//新增品牌
    updateTrademark = '/admin/product/baseTrademark/update',//修改已有的品牌的接口
    removeTrademark="/admin/product/baseTrademark/remove/"
}

//获取已有品牌接口函数
export const reqTrademark = (page: number, limit: number) => request.get<any, responseData>(API.trademark + `${page}/${limit}`);

//新增或者修改品牌数据
export const reqAddOrUpdateTrademark = (data: trademark) => {
    //请求体携带参数(对象):拥有ID,已有品牌,更新
    if (data.id) {
        return request.put(API.updateTrademark, data);
    } else {
        //新增品牌
        return request.post(API.addTrademark, data);
    }
}

//删除某一个品牌的接口
export const reqRemoveTrademark = (id:number)=>request.delete(API.removeTrademark+id);